package duilibhx.ui;
import cpp.Lib;
import duilibhx.events.Event;
import duilibhx.utils.PaintManager;
/**
 * ...
 * @author wangjian QQ:421924396
 */

class Window extends UIBase
{
	private var _paintManager:PaintManager;
	public function new():Void 
	{
		super(dui_window_new(this));
	}
	public function centerWindow():Void {
		dui_window_centerwindow(duilib_handle);
	}
	public function getPaintManager():PaintManager {
		if (_paintManager == null) {
			untyped _paintManager = new PaintManager();
			untyped _paintManager.init(dui_window_get_paintmanager(duilib_handle,_paintManager));
		}
		return _paintManager;
	}
	public function showWindow(isShow:Bool=true,takeFocus:Bool=true):Void {
		dui_window_show_window(duilib_handle, isShow, takeFocus);
	}
	
	private function handleMessage(inFields:Dynamic):Int {
		var msgId:Int = inFields.f0;
		var wParam:Int = inFields.f1;
		var lParam:Int = inFields.f2;
		return onMessage(msgId,wParam,lParam);
	}
	public function onMessage(msgId:Int,wParam:Int,lParam:Int):Int {
		return -1;
	}
	public  function onNotify(event:Notify):Void {
		
	}
	//private function on_notify(event:Dynamic):Void {
		//
		//if (event.sender) {
			//
		//}
	//}
	public function showModal():Int {
		return 0;
	}
	
	public function create(?_title:String=""):Void {
		dui_window_create(duilib_handle, _title);
	}
	public function close(?retId:Int=1):Void {
		dui_window_close(duilib_handle,retId);
	}
	public function resizeClient(cx:Int=-1,cy:Int=-1):Void {
		
	}
	public function getClassStyle():Int {
		return 0;
	}
	
	public function sendMessage(msgId:Int, wParam:Int, lParam:Int):Int {
		return dui_window_sendmessage(duilib_handle,msgId,wParam,lParam);
	}
	public function postMessage(msgId:Int, wParam:Int, lParam:Int):Int {
		return dui_window_postmessage(duilib_handle,msgId,wParam,lParam);
	}
	static var dui_window_centerwindow = Lib.load("DuiLib","dui_window_centerwindow", 1);
	static var dui_window_new = Lib.load("DuiLib","dui_window_new", 1);
	static var dui_window_show_window = Lib.load("DuiLib", "dui_window_show_window", 3);
	static var dui_window_sendmessage = Lib.load("DuiLib", "dui_window_sendmessage", 4);
	static var dui_window_postmessage = Lib.load("DuiLib", "dui_window_postmessage", 4);
	static var dui_window_close = Lib.load("DuiLib", "dui_window_close", 2);
	static var dui_window_create = Lib.load("DuiLib", "dui_window_create", 2);
	static var dui_window_get_paintmanager=Lib.load("DuiLib", "dui_window_get_paintmanager",2);
}


//public:
    //CWindowWnd();
//
    //HWND GetHWND() const;
    //operator HWND() const;
//
    //bool RegisterWindowClass();
    //bool RegisterSuperclass();
//
    //HWND Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle, const RECT rc, HMENU hMenu = NULL);
    //HWND Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle, int x = CW_USEDEFAULT, int y = CW_USEDEFAULT, int cx = CW_USEDEFAULT, int cy = CW_USEDEFAULT, HMENU hMenu = NULL);
    //HWND Subclass(HWND hWnd);
    //void Unsubclass();
    //void ShowWindow(bool bShow = true, bool bTakeFocus = true);
    //UINT ShowModal();
    //void Close(UINT nRet = IDOK);
    //void CenterWindow();
    //void SetIcon(UINT nRes);
//
    //LRESULT SendMessage(UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0L);
    //LRESULT PostMessage(UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0L);
    //void ResizeClient(int cx = -1, int cy = -1);